package org.reliablesource.prism.gef.editor.commands;

import org.eclipse.draw2d.Bendpoint;
import org.reliablesource.prism.gef.editor.model.WireBendpoint;

public class MoveBendpointCommand extends BendpointCommand {

	private Bendpoint oldBendpoint;

	public void execute() {
		WireBendpoint bp = new WireBendpoint();
		bp.setRelativeDimensions(getFirstRelativeDimension(),
				getSecondRelativeDimension());
		setOldBendpoint((Bendpoint) getWire().getBendpoints().get(getIndex()));
		getWire().setBendpoint(getIndex(), bp);
	}

	protected Bendpoint getOldBendpoint() {
		return oldBendpoint;
	}

	public void setOldBendpoint(final Bendpoint bp) {
		oldBendpoint = bp;
	}

	public void undo() {
		super.undo();		
		getWire().setBendpoint(getIndex(), getOldBendpoint());
	}

}
